﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace DoAnB
{
    public partial class tkDoanhThuNV : Form
    {
        public tkDoanhThuNV()
        {
            InitializeComponent();
            string sql = "Select MaNV, TenNV FROM NhanVien";
            ketnoi data = new ketnoi();
            cbbNhanVien.DataSource = data.getDataTable(sql);
            cbbNhanVien.DisplayMember = "TenNV";
            cbbNhanVien.ValueMember = "MaNV";

        }

        private void btXem_Click(object sender, EventArgs e)
        {
            ketnoi data = new ketnoi();
            DataTable table = new DataTable();
            
            int manv = int.Parse(cbbNhanVien.SelectedValue.ToString());
            string sql = "SELECT NgayBan, GiaTri, MaNV FROM HoaDon WHERE NgayBan = " + "'" + dtpTKNgay.Value.ToString("yyyy-MM-dd") +"' AND MaNV = " + manv;
            table = data.getDataTable(sql);
            int rows = table.Rows.Count;
            lblQuantityHD.Text = rows.ToString();
            double t = 0;
            foreach (DataRow Row in table.Rows)
            {
                t += double.Parse((Row[1]).ToString());
            }
            lblTotalBill.Text = t.ToString("###,###,##0");
        }
    }
}
